package com.syerit.modules.utils
{
	import beherit.fl.transitions.utils.ITransition;
	import beherit.fl.transitions.utils.TransitionEvent;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.events.EventDispatcher;
	
	import gs.TweenLite;
	
	public class BasicModuleTransition extends EventDispatcher implements ITransition
	{
		//add transition event
		
		private var _parentContainer:DisplayObjectContainer;
		
		public function BasicModuleTransition()
		{
		}
		public function change(outObj:Bitmap,inObj:Bitmap):void
		{
			//_parentContainer.addChild(outObj);
			_parentContainer.addChild(inObj);
			outObj.x=0;
			inObj.x=-1260;
			TweenLite.to(inObj,2,{x:0,onComplete:onTransitionComplete});
			TweenLite.to(outObj,2,{x:1260});
			//TweenLite.to(outObj,2,{alpha:0});
		}
		public function set parentContainer(parent:DisplayObjectContainer):void
		{
			_parentContainer=parent;
		}
		private function onTransitionComplete():void
		{
			_parentContainer.removeChildAt(1);
			_parentContainer.removeChildAt(0);
			dispatchEvent(new TransitionEvent(TransitionEvent.FINISHED));
			//_parentContainer.visible=false;
		}

	}
}